﻿#include "dialog.h"
#include "ui_dialog.h"
#include <QDebug>
DialogRemoteThreadParam::DialogRemoteThreadParam(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
}

DialogRemoteThreadParam::~DialogRemoteThreadParam()
{
    qDebug()<<" delete ui;";
    delete ui;
}
//获取单选框的值
int DialogRemoteThreadParam::GetRadioButtonValue()
{
    if (ui->RadioButtonRunNow->isChecked())
    {
        return 0;
    }else if(ui->RadioButtonSuspend->isChecked())
    {
        return CREATE_THREAD_SUSPENDED;
    }
    return 0;
}
//获取线程入口值
ULONG_PTR DialogRemoteThreadParam::GetThreadEntryValue()
{

    QString threadEntryText =  ui->LineEditThreadEntry->text();
    threadEntryText=threadEntryText.trimmed();
    //判断输入的地址是否为空
    if (threadEntryText.isEmpty())
    {
        return 0;
    }
    if (threadEntryText.startsWith("0X",Qt::CaseInsensitive))
    {
        threadEntryText.remove(0,2);
    }
    ULONG_PTR threadEntryPoint = (ULONG_PTR)threadEntryText.toULongLong(NULL,16);
    return threadEntryPoint;
}
//获取线程参数值
ULONG_PTR DialogRemoteThreadParam::GetThreadParamValue()
{
    QString ThreadParamText =  ui->LineEditThreadParam->text();
    ThreadParamText=ThreadParamText.trimmed();
    //判断输入的地址是否为空
    if (ThreadParamText.isEmpty())
    {
        return 0;
    }
    ULONG_PTR ThreadParam=0;
    if (ThreadParamText.startsWith("0X",Qt::CaseInsensitive))
    {
        ThreadParamText.remove(0,2);
        ThreadParam = (ULONG_PTR)ThreadParamText.toULongLong(NULL,16);
    }else{
        ThreadParam = (ULONG_PTR)ThreadParamText.toULongLong(NULL,10);
    }
    return ThreadParam;
}

void DialogRemoteThreadParam::on_ButtonYes_clicked()
{
    //QDialog::accept();
    QDialog::done(QDialog::Accepted);
}

void DialogRemoteThreadParam::on_ButtonCancel_clicked()
{
    //QDialog::reject();
    QDialog::done(QDialog::Rejected);
}
